<?php if (!defined('FIT_PATH')) exit('No direct script access allowed');
/**
 * @copyright 2009 - 2011 Bincent.com. All Rights Reserved.
 * @license http://www.apache.org/licenses/LICENSE-2.0
 * @package FitPHP
 * @subpackage helper
 * 
 * @author Hongbin Hsu <hongbin.hsu@gmail.com> Initial.
 * @version $Id: helper/security.php 1.0 2009-07-18 13:34 hongbin.hsu $
 */

// ------------------------------------------------------------------------

/**
 * XSS过滤
 *
 * @access	public
 * @param	string
 * @param	bool	$is_image	是否是图像
 * @return	string
 */	
if (!function_exists('xss_clean'))
{
	function xss_clean($str, $is_image = FALSE)
	{
		
	}
}

// --------------------------------------------------------------------

/**
 * 将字符串散列化(Hash)
 *
 * @access	public
 * @param	string
 * @return	string
 */	
if (!function_exists('dohash'))
{	
	function dohash($str, $type = 'sha1')
	{
		
	}
}
	
// ------------------------------------------------------------------------

/**
 * 去除图像标签
 *
 * @access	public
 * @param	string $str
 * @return	string
 */	
if (!function_exists('strip_image_tags'))
{
	function strip_image_tags($str)
	{
		$str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
		$str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
			
		return $str;
	}
}
	
// ------------------------------------------------------------------------

/**
 * 转换PHP标签
 *
 * @access	public
 * @param	string	$str
 * @return	string
 */	
if (!function_exists('encode_php_tags'))
{
	function encode_php_tags($str)
	{
		return str_replace(array('<?php', '<?PHP', '<?', '?>'),
		array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
	}
}